/*
 区公会-街道-基层联动
*/
$(document).ready(function(){
	hideWaitIcon();					   				   
	$("#zoneunion").change(function(){	
		$.ajax({
			type: "get",
			url: "/organization/personnel/queryByZoneunion.action",
			data: "organization_id="+$("#zoneunion").val(),
			cache: false,
			async:false, 
			beforeSend: function(){
				$("#wait00-1").show();$("#ok00-1").hide();
			},
			complete: function(){
				$("#wait00-1").hide();$("#ok00-1").show();
			},
			success: function(resp){
				$("#streetunion").empty(); 
				$("#localunion").empty(); 
				
				$("#streetunion").append('<option value="">请选择街道工会</option>'); 
				$("#localunion").append('<option value="">请选择基层工会</option>'); 
				
				/*jquery1.4以上版本用法*/
				var rs = eval(resp).organizationList;  //转换为json对象
				
				/*jquery1.4以下版本的用法*/
				//var rs = eval("("+resp+")").cityList;  //转换为json对象
				
				for(var i=0;i<rs.length;i++){
					$("#streetunion").append("<option value='"+rs[i].organization_id+"'>"+rs[i].organization_name+"</option>");  
				}				
			}
		});
	});	
	
	$("#streetunion").change(function(){	
		$.ajax({
			type: "get",
			url: "/organization/personnel/queryByZoneunion.action",
			data: "organization_id="+$("#streetunion").val(),
			cache: false,
			async:false, 
			beforeSend: function(){
				$("#wait00-1").show();$("#ok00-1").hide();
			},
			complete: function(){
				$("#wait00-1").hide();$("#ok00-1").show();
			},
			success: function(resp){
				$("#localunion").empty(); 
				$("#localunion").append('<option value="">请选择基层工会</option>'); 
				
				/*jquery1.4以上版本用法*/
				var rs = eval(resp).organizationList;  //转换为json对象
				
				/*jquery1.4以下版本的用法*/
				//var rs = eval("("+resp+")").livingareaList;  //转换为json对象
				
				for(var i=0;i<rs.length;i++){
					$("#localunion").append("<option value='"+rs[i].organization_id+"'>"+rs[i].organization_name+"</option>");  
				}				
			}
		});
	});		
});

function hideWaitIcon(){
	$("#wait00-1").hide();
	$("#ok00-1").hide();
}